from flask import Blueprint
from flask_restplus import Api
from utils.errors import default_jwt_error_handler

class RouteManageMent(object):
    def __init__(self, name, import_name, urls_map):
        self.route_resource = Blueprint(name, import_name)
        self.api_resource = Api(self.route_resource)
        self.api_resource.errorhandler(default_jwt_error_handler)
        self.add_urls_map(urls_map)

    def get_route_resource(self):
        return self.route_resource

    def get_api_resource(self):
        return self.api_resource

    def add_urls_map(self, urls_map):
        for url in urls_map:
            self.api_resource.add_resource(urls_map[url], url)

